package com.healthcarex.hip.saas.common.util.xml;

import org.apache.commons.lang3.StringUtils;

import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 * *******description*******
 * JAXB 自定义CDATA XmlAdaper
 * *************************
 *
 * @author ChenPan
 * @date 2018/8/30 10:50
 */
public class CDATASectionAdapter extends XmlAdapter<String, String> {
    @Override
    public String unmarshal(String v) throws Exception {
        return v;
    }

    @Override
    public String marshal(String v) throws Exception {
        if (StringUtils.isNotBlank(v)) {
            return "<![CDATA[" + v + "]]>";
        }
        return null;
    }
}
